package com.gitee.zycra.future.job.common.param;

import com.gitee.zycra.future.job.common.model.JobSchedule;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @author zycra
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class UpdateScheduleParam {

    /**
     * 主键
     */
    private Long id;

    /**
     * 调度名称
     */
    private String scheduleName;

    /**
     * 执行参数
     */
    private String scheduleParam;

    /**
     * 是否开启(0:否,1:是)
     */
    private Boolean scheduleEnable;

    /**
     * 月
     */
    private Integer cronMonth;

    /**
     * 日
     */
    private Integer cronDay;

    /**
     * 时
     */
    private Integer cronHour;

    /**
     * 分
     */
    private Integer cronMinute;

    /**
     * 秒
     */
    private Integer cronSecond;

    public static JobSchedule convertToJobSchedule(UpdateScheduleParam updateScheduleParam) {
        if (updateScheduleParam == null) {
            return null;
        }
        return new JobSchedule().setId(updateScheduleParam.getId())
                .setScheduleName(updateScheduleParam.getScheduleName())
                .setScheduleParam(updateScheduleParam.getScheduleParam())
                .setScheduleEnable(updateScheduleParam.getScheduleEnable())
                .setCronMonth(updateScheduleParam.getCronMonth())
                .setCronDay(updateScheduleParam.getCronDay())
                .setCronHour(updateScheduleParam.getCronHour())
                .setCronMinute(updateScheduleParam.getCronMinute())
                .setCronSecond(updateScheduleParam.getCronSecond());
    }

}
